package com.cmdfut.rxjava.rxjava;

/**
 * @ClassName: BasicFuseableObserver
 * @Description:
 * @Author: greenlee
 * @Date: 2020/6/11 10:44
 */
public abstract class BasicFuseableObserver<T, R> implements Observer<T>, Disposable<R> {

    //观察者
    protected final Observer<? super R> actual;
    protected Disposable disposeble;

    public BasicFuseableObserver(Observer<? super R> actual) {
        this.actual = actual;
    }

    @Override
    public void onSubscribe(Disposable d) {
        this.disposeble = d;
        actual.onSubscribe(d);
    }

    @Override
    public void onError(Throwable e) {
        actual.onError(e);
    }

    @Override
    public void onComplete() {
        actual.onComplete();
    }

    @Override
    public void dispose(boolean bool) {
        disposeble.dispose(bool);
    }

    @Override
    public boolean isDisposed() {
        return disposeble.isDisposed();
    }
}
